using SalesPages.DomainModel;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class RioPrizeMap : EntityTypeConfiguration<RioPrize>
    {
        public RioPrizeMap()
        {
            // Primary Key
            this.HasKey(t => t.RioPrizeId);

            // Properties
            this.Property(t => t.Country)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(2);

            // Table & Column Mappings
            this.ToTable("RioPrize");
            this.Property(t => t.RioPrizeId).HasColumnName("RioPrizeId");
            this.Property(t => t.PrizeType).HasColumnName("PrizeType");
            this.Property(t => t.RioUserId).HasColumnName("RioUserId");
            this.Property(t => t.PrizeStatus).HasColumnName("PrizeStatus");
            this.Property(t => t.CreatedDate).HasColumnName("CreatedDate");
            this.Property(t => t.RedeemDate).HasColumnName("RedeemDate");
            this.Property(t => t.Country).HasColumnName("Country");

            // Relationships
            this.HasRequired(t => t.RioUser)
                .WithMany(t => t.RioPrizes)
                .HasForeignKey(d => d.RioUserId);

        }
    }
}
